#include "Junction.h"

const float Junction::MOTOR_SPEED_DELTA = 1000.0f;
const float Junction::MOTOR_TORQUE_DELTA = 100.0f;

Junction::Junction( std::string id ) :
	Part( id ),
	_joint( 0 )
{
}

Junction::~Junction( )
{
}

void Junction::SetJoint( physics::IHingeJoint* joint )
{
	_joint = joint;
}

physics::IHingeJoint* Junction::GetJoint( ) const
{
	return _joint;
}

void Junction::PerformAction( const Action& action )
{
	switch( action )
	{
	case StartLeftRotation:
		_joint->SetMotorSpeed( _joint->GetMotorSpeed( ) + MOTOR_SPEED_DELTA );
		//_joint->SetMotorTorque( _joint->GetMotorTorque( ) + MOTOR_TORQUE_DELTA );
		return;
	case StopLeftRotation:
		_joint->SetMotorSpeed( _joint->GetMotorSpeed( ) - MOTOR_SPEED_DELTA );
		//_joint->SetMotorTorque( _joint->GetMotorTorque( ) - MOTOR_TORQUE_DELTA );
		return;
	case StartRightRotation:
		_joint->SetMotorSpeed( _joint->GetMotorSpeed( ) - MOTOR_SPEED_DELTA );
		//_joint->SetMotorTorque(  _joint->GetMotorTorque( ) + MOTOR_TORQUE_DELTA );
		return;
	case StopRightRotation:
		_joint->SetMotorSpeed( _joint->GetMotorSpeed( ) + MOTOR_SPEED_DELTA );
		//_joint->SetMotorTorque( _joint->GetMotorTorque( ) - MOTOR_TORQUE_DELTA );
		return;
	default:
		return;
	}
}

void Junction::Update( float )
{

}

void Junction::Draw( ) const
{
}
